package edu.yonsei.iwb.smarttv.model;

import com.hp.hpl.jena.graph.Node;
import com.hp.hpl.jena.rdf.model.Resource;

/**
 * Node와 Property 및 그들의 타입을 표현하기 위한 클래스
 * 
 * @author Joo
 */
public class ResourceNode {

    protected Resource node;
    protected int type;
    private Resource instance;
    private String instanceURI;
    private Node variableNode;
    

    // 생성자중 노드가 파라미터로 들어오면 직접 타입정보까지 class로 변경.
    public ResourceNode(MNode node) {
        this.node = node.getNode();
        this.type = node.getType();
    }
    
    public ResourceNode(MNode node, Resource instance) {
        this.node = node.getNode();
        this.type = NodeType.INSTANCE_TYPE;
        this.instance = instance;
        this.instanceURI = instance.getURI();
        this.variableNode = instance.asNode();
    }
        

    public ResourceNode(Resource node, int type) {
        this.node = node;
        this.type = type;
    }
    
    public void setVariableNode(Node variable){
        this.variableNode = variable;        
    }
    
    public void setInstanceURI(String instanceURI) {
        this.instanceURI = instanceURI;
    }
    
    public Node getVariableNode(){
        return this.variableNode;
    }
    
    public Resource getInstance(){
        return this.instance;
    }
    public String getInstanceURI() {
        return this.instanceURI;
    }
    
    public Resource getNode() {
        return this.node;
    }

    public int getType() {
        return this.type;
    }

    @Override
    public String toString() {
        return this.node.getURI();
    }
}
